#include <bits/stdc++.h>

using namespace std;

class Solution {
public:
	int findLHS(vector<int>& nums) {
		int res = 0;
		unordered_map<int, int> freq;
		for (int num : nums)
			freq[num]++;
		for (auto [key, val] : freq) if (freq.count(key + 1))
				res = max(res, val + freq[key + 1]);

		return res;
	}

private:
};

int main()
{
	Solution solution;
	return 0;
}
